//2009/08/30 00:13:21
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class MagicSpell
{
public:
    string fixTheSpell(string spell)
    {
        vector<char> s;
        for (int i=0; i<spell.size(); i++)
            if (spell[i] =='A' || spell[i] == 'Z')
                s.push_back(spell[i]);
        //s.reverse(s.begin(), s.end());
        int idx = s.size() - 1;
        for (int i=0; i<spell.size(); i++)
            if (spell[i] =='A' || spell[i] == 'Z')
                spell[i] = s[idx--];
        return spell;
    }
};
